package com.kob.backend.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.kob.backend.pojo.product;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface ProductMapper extends BaseMapper<product> {
    @Select("select product.* from product where productname like CONCAT('%', #{search_content}, '%') or product.description like CONCAT('%', #{search_content}, '%')")
    List<product> search_product(String search_content);
    @Select("select * from product where price>=#{min_price} and price<=#{max_price}")
    List<product> searchByprice(@Param("min_price") Double min_price, @Param("max_price")Double max_price);

    @Select("update product set inventory=inventory-1 where id=#{productid}")
    void inventoryminus(@Param("productid") Integer productid);
}
